package com.china08.yxyapi.repository.db;

import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.china08.yxyapi.entity.db.meeting.VideoMeeting;

public interface VideoMeetingRepository extends JpaRepository<VideoMeeting, String> {

    VideoMeeting findById(String id);

    VideoMeeting findByRoomId(String roomId);

    List<VideoMeeting> findByIdInOrderByCreatedDateDesc(List<String> ids);

    VideoMeeting findByIdAndSpeakerId(String id, String speakerId);

    VideoMeeting findByIdAndSpeakerIdAndSchoolId(String id, String speakerId, String schoolId);

    Page<VideoMeeting> findBySchoolIdAndTitleContainingAndStatus(String schoolId, String title, Integer status,
            Pageable pageable);

    Page<VideoMeeting> findBySchoolIdAndStatus(String schoolId, Integer status, Pageable pageable);

    Page<VideoMeeting> findBySchoolIdAndTitleContaining(String schoolId, String title, Pageable pageable);

    Page<VideoMeeting> findBySchoolId(String schoolId, Pageable pageable);

    List<VideoMeeting> findByStatusAndStartDateBetween(Integer status, Date startDate, Date endDate);

    List<VideoMeeting> findByStatusAndStartDateLessThanEqual(Integer status, Date startDate);

    List<VideoMeeting> findByStatusAndEndDateLessThanEqual(Integer status, Date endDate);

    @Query(value = "select * from yxy_yxy.yxy_video_meeting where status = 2 and actual_end_date is not null and actual_end_date <= ? and actual_end_date >= ?", nativeQuery = true)
    List<VideoMeeting> findByEnd(String nowdate, String befordate);
}
